<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<!-- jQuery 2.2.3 -->
	<script th:src="@{/admin/plugins/jQuery/jquery-2.2.3.min.js}"></script>
<script type="text/javascript">
    function uploadFile() {
        //将表单封装为一个formData对象
        var formData = new FormData($('#fileUploadForm')[0]);
        $.ajax({
            url:'http://127.0.0.1:8080/admin/file',
            type:'POST',
            //将formData对象作为参数进行上传
            data:formData,
            contentType: false,
            processData: false,
            success:function (data) {
                if(data.error==0){
                    //文件上传成功后的处理
                    $('#showUploadContent').append('<div>name:'+data.name+'<br/>url:'+data.url+'<img src="http://192.168.1.107/'+data.url+'"></div>')
                }
            }
        })
    }
    $(function () {
        //为提交按钮添加点击事件
        $('#commit').click(function () {
            uploadFile();
        })
    })
</script>
<body>
<form id="fileUploadForm">
    <input type="file" name="uploadFile" class="imageUpload"/>
    <span id="commit">提交到服务器</span>
</form>
<div id="showUploadContent">

</div>

</body>
</html>